import request from '@/utils/request.js'
import store from '@/store/index.js'
// 登录接口
export function authorizations (data) {
  return request({
    url: '/v1_0/authorizations',
    method: 'post',
    data,
    noToken: true
  })
}
// 发送验证码
export const smsCodes = mobile => {
  return request({ url: `/v1_0/sms/codes/${mobile}` })
}
export function userProfile () {
  return request({ url: '/v1_0/user/profile' })
}
export function userProfilePatch (data) {
  return request({
    url: '/v1_0/user/profile',
    method: 'patch',
    data
  })
}
export function userPhoto (data) {
  return request({ url: '/v1_0/user/photo', method: 'patch', data })
}

export function authorizationsPut () {
  return request({
    url: '/v1_0/authorizations',
    method: 'put',
    noToken: true,
    headers: {
      Authorization: `Bearer ${store.state.user.refresh_token}`
    }
  })
}
